# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


class MyspiderPipeline(object):

    def __init__(self):
        # 创建文件对象
        self.file = open("../data/comment.txt", "a", encoding="utf-8")

    def process_item(self, item, spider):
        # 将爬取过来的数据铁路磁盘
        print(item["line"])
        self.file.write(item["line"])
        self.file.write("\n")
        self.file.flush()
